﻿/*
   @Description:agency系统设置js
   @Author:wk
   @Date:2014-08-10 
 */
var systemParameterSettings = {};

//删除动态添加的参数项文本框信息
systemParameterSettings.DelSysParameterItem = function (e) {
    $(e).parent().remove();
}

//添加爱多个参数文本输入框事件
systemParameterSettings.AddSysParameterItem = function (systemParameterType) {
    //只有房源跟进状态才显示这个
    if (systemParameterType == 64) {
        $(".sysValue").css("display", "inline-block");
    }
    else {
        $(".sysValue").css("display", "none");
    }
    if (systemParameterType == 83) {
        $(".spanPropertyStatus").css("display", "inline-block")
    }
    else {
        $(".spanPropertyStatus").css("display", "none");
    }
    //当时房源标签的时候，需要选择颜色
    if (systemParameterType == 27 || systemParameterType == 58) {
        $(".sysStyle").css("display", "inline-block");
    }
    else {
        $(".sysStyle").css("display", "none");
    }
    $("#addSystemParameter .addItemName").click(function () {
        $("#addSystemParameter").find(".saveInfo").after($(".addItem").html());
        //设置可以选择颜色的控件
        var i = 0;
        $("#addSystemParameter").find(".seqItem").each(function () {
            i++;
            if (i > 1) {
                $(this).find(".txtstyle").unbind();
                var lastDepartName = $(this).find(".txtstyle").attr("id", "f" + i);
                $("#addSystemParameter #" + lastDepartName.attr("id") + "").bigColorpicker(lastDepartName.attr("id"), "L", 10);
            }
        });
        $("#f333").bigColorpicker("f3", "L", 6);
    });
}

//blur事件的验证
systemParameterSettings.verify = function (isIntSelector, isnotNullSelector, issameSelector, isstylesameSelector, isvaluesameSelector, contextSelector) {
    //验证排序输入框只能输入数字
    agencyVerify.nonnegativeIntInput(isIntSelector, true);
    //验证数据不为空
    agencyVerify.notNullInput(null, isnotNullSelector, true, "blur");

    //验证输入的部门是否有重复的
    agencyVerify.NoInputSame(contextSelector, issameSelector, "blur", "参数名称不能重复");

    agencyVerify.NoInputSame(contextSelector, isstylesameSelector, "blur", "样式不能重复");

    agencyVerify.NoInputSame(contextSelector, isvaluesameSelector, "blur", "显示值不能重复");

    //触发blur事件填充颜色
    agencyVerify.SetColor(contextSelector, isstylesameSelector, "blur");

};

//点击保存按钮进行验证
systemParameterSettings.ClickVerify = function (isIntSelector, isnotNullSelector, isCheckSelector, issameSelector, isstylesameSelector, isvaluesameSelector) {
    $(isIntSelector).blur();
    $(isnotNullSelector).blur();
    $(issameSelector).blur();
    $(isstylesameSelector).blur();
    $(isvaluesameSelector).blur();
    if ($(isCheckSelector).length > 0) {
        return false;
    }
    else {
        return true;
    }
};


$(function () {

    //刷新系统业务设置
    $(".refreshData").click(function () {
        $.AjaxAgency("/system/refresh-sysparameter", null, function (data) {
            if (data == "OK") {
                $.OKDialogAgency('<div class="tc">任务已提交,系统后台正在处理！</div>');
            }
            else {
                $.OKDialogAgency('<div class="tc">' + data + '</div>');
            }
        });
    });
    //添加系统参数事件 start
    $(".argumentsSet .addSysParameter").bind("click", function () {
        //获取参数枚举类型值
        var systemParameterType = $(this).attr("sysParaType");
        //获取参数类型名称
        var sysParamTypeName = $(this).parent().parent().prev().text();
        //只有房源跟进状态才显示这个
        if (systemParameterType == 64) {
            $(".sysValue").css("display", "inline-block");
            $(".txtItemValue").attr("notnull", "1");
        }
        else {
            $(".sysValue").css("display", "none");
            $(".txtItemValue").removeAttr("notnull");
        }
        //当是客户状态的时候，显示出选择的类型
        if (systemParameterType == 83) {
            $(".spanPropertyStatus").css("display", "inline-block");
        }
        else {
            $(".spanPropertyStatus").css("display", "none");
        }
        //当时房源标签的时候，需要选择颜色
        if (systemParameterType == 27 || systemParameterType == 58) {
            $(".sysStyle").css("display", "inline-block");
            $(".txtstyle").attr("notnull", "1");
        }
        else {
            $(".sysStyle").css("display", "none");
            $(".txtstyle").removeAttr("notnull");
        }
        //弹层显示拼接的元素
        $.dialog({
            id: "dialogSystemParameterSettings",
            lock: true,
            title: sysParamTypeName,
            content: '<span id="addSystemParameter">  <input type="hidden" class="addSystemParameterType" id="addSystemParameterTypeId" value="' + systemParameterType + '" /> ' + $("#addArguments").html() + '</span>'
        });
        //弹层后再层中动态添加参数项
        systemParameterSettings.AddSysParameterItem(systemParameterType);
        //验证输入框
        systemParameterSettings.verify("#addSystemParameter input[isint=1]", "#addSystemParameter input[notnull=1]", "#addSystemParameter input[issame=1]", "#addSystemParameter input[isstylesame=1]", "#addSystemParameter input[isvaluesame=1]", "#addSystemParameter");

        $("#addSystemParameter #f0").bigColorpicker("f0", "L", 10);
        $("#f333").bigColorpicker("f3", "L", 6);
        //保存数据
        $("#addSystemParameter .addSystemParameter").click(function () {
            //保存按钮的非空验证
            if (systemParameterSettings.ClickVerify("#addSystemParameter input[isint=1]", "#addSystemParameter input[notnull=1]", "#addSystemParameter .checkError", "#addSystemParameter input[issame=1]", "#addSystemParameter input[isstylesame=1]", "#addSystemParameter input[isvaluesame=1]")) {
                var ItemNames = [], Seqs = [], ItemValues = [], styleValues = [], sysValues = [];
                //获取多个值
                $("#addSystemParameter").find(".seqItem").each(function () {
                    ItemNames[ItemNames.length] = $(this).find(".txtItemName").val();
                    Seqs[Seqs.length] = $(this).find(".txtSeq").val();
                    //只有房源状态有
                    ItemValues[ItemValues.length] = $(this).find(".PropertyStatus").val();
                    //只有房源标签和客源标签有
                    styleValues[styleValues.length] = $(this).find(".txtstyle").val();
                    //只有房源跟进类型有
                    sysValues[sysValues.length] = $(this).find(".txtItemValue").val();
                });
                var url = "/System/Add-SystemParameter";
                var reqData = {
                    "ParameterType": $("#addSystemParameter").find(".addSystemParameterType").val(),
                    "ItemName": ItemNames.join(","),
                    "Seq": Seqs.join(","),
                    "ItemValue": ItemValues.join(","),
                    "styleValue": styleValues.join(','),
                    "sysValue": sysValues.join(',')
                };
                $.AjaxAgency(url, reqData, function (data) {
                    if (data == "OK") {
                        $.OKDialogAgency('<div class="tc">操作成功！</div>', '提示', function () {
                            art.dialog.get("dialogSystemParameterSettings").close();
                            window.location.reload();
                        });
                    }
                    else {
                        $.OKDialogAgency('<div class="tc">' + data + '</div>');
                    }
                });
            }
        });
    });
    //添加系统参数事件 end


    //编辑事件 start
    //保存编辑的信息
    systemParameterSettings.editSystemParameter = function () {
        $("#editSystemParameter").find(".editSave").click(function () {
            //保存按钮的非空验证
            if (systemParameterSettings.ClickVerify("#editSystemParameter input[isint=1]", "#editSystemParameter input[notnull=1]", "#editSystemParameter .checkError", "#editSystemParameter input[issame=1]", "#editSystemParameter input[isstylesame=1]", "#editSystemParameter input[isvaluesame=1]")) {
                var ItemNames = [], Seqs = [], ItemKeyIds = [], ItemStatus = [], styleValues = [], sysValues = [];
                //获取多个值
                $("#editSystemParameter").find(".seqItem").each(function () {
                    ItemKeyIds[ItemKeyIds.length] = $(this).find(".sysParameterKey").val();
                    ItemNames[ItemNames.length] = $(this).find(".txtItemName").val();
                    Seqs[Seqs.length] = $(this).find(".txtSeq").val();
                    ItemStatus[ItemStatus.length] = $(this).find(".PropertyStatus").val();
                    styleValues[styleValues.length] = $(this).find(".txtstyle").val();
                    //只有房源跟进类型有
                    sysValues[sysValues.length] = $(this).find(".txtItemValue").val();
                });
                var url = "/System/Modify-SysParameterDetail";
                var reqData = {
                    "ParameterType": $("#editSystemParameter").find(".addSystemParameterType").val(),
                    "ItemName": ItemNames.join(","),
                    "Seq": Seqs.join(","),
                    "ItemKeys": ItemKeyIds.join(","),
                    "ItemValue": ItemStatus.join(","),
                    "styleValue": styleValues.join(","),
                    "sysValue": sysValues.join(',')
                };
                $.AjaxAgency(url, reqData, function (data) {
                    if (data == "OK") {
                        $.OKDialogAgency('<div class="tc">操作成功！</div>', '提示', function () {
                            art.dialog.get("dialogEditSystemParameterSettings").close();
                            window.location.reload();
                        });
                    }
                    else {
                        $.OKDialogAgency('<div class="tc">' + data + '</div>');
                    }
                });
            }
        });
    };
    //编辑事件
    $(".argumentsSet .editSysParameter").bind("click", function () {
        //获取参数枚举类型值
        var systemParameterType = $(this).attr("sysParaType");
        //获取参数类型名称
        var sysParamTypeName = $(this).parent().parent().prev().text();
        var url = "/System/Find-SysParameterDetail";
        var reqData = {
            "ParameterType": systemParameterType,
        };
        $.AjaxAgency(url, reqData, function (data) {
            if (data.Flag) {
                //先清空，在拼接
                $("#editArguments").empty();
                if (data.Result.Items.length > 0) {
                    //弹层显示拼接的元素
                    for (var i = 0; i < data.Result.Items.length; i++) {
                        if (data.Result.Items[i].Style == "null" || data.Result.Items[i].Style == null) {
                            data.Result.Items[i].Style = "";
                        }
                        var rowHtml = '<div class="info-list seqItem clearfix h26lh26" style="width:auto !important;min-width:362px;width:362px;"><label class="l"><strong class="public" style="width:75px;"><em class="star">*</em>显示排序：</strong>'
                    + '<input type="text" class="ipt w50 txtSeq" value="' + data.Result.Items[i].Seq + '" isint="1" maxlength="10" notnull="1"/></label>'
                    + '<label class="l"><strong class="public" style="width:83px;"><em class="star">*</em>参数名称：</strong>'
                    + '<input type="text" class="ipt txtItemName" value="' + data.Result.Items[i].ItemName + '" maxlength="10" notnull="1" issame="1"/></label>'
                    + '<input type="hidden" class="sysParameterKey" value="' + data.Result.Items[i].KeyId + '"/>'
                    + '<div class="sysValue l h26lh26" style="display: none;">'
                    + '<strong class="public" style="width:71px;"><em class="star">*</em>显示值：</strong>'
                    + '<input type="text" class="ipt l txtItemValue" value="' + data.Result.Items[i].ItemValue + '" maxlength="10" notnull="1" isvaluesame="1" /></div>'
                    + '<div class="sysStyle l h26lh26" style="display:none;">'
                    + '<strong class="public" style="width:83px;"><em class="star">*</em>标签样式：</strong>'
                    + '<label style="background-color: ' + data.Result.Items[i].Style + ';" class="dib w30 l white-label"></label>'
                    + '<input type="text" id="f"' + i.toString() + '"" value="' + data.Result.Items[i].Style + '" class="ipt txtstyle" isstylesame="1"/></div>'
                    + '<span class="spanPropertyStatus" style="display: none;float:left;">'
                    + '<strong class="public" style="width:50px;">类型：</strong>'
                        if (data.Result.Items[i].ItemValue == 1) {
                            rowHtml = rowHtml + '<lable id="PropertyStatus">有效</lable>'
                        }
                        if (data.Result.Items[i].ItemValue == 2) {
                            rowHtml = rowHtml + '<lable id="PropertyStatus">暂缓</lable>'
                        }
                        if (data.Result.Items[i].ItemValue == 3) {
                            rowHtml = rowHtml + '<lable id="PropertyStatus">预定</lable>'
                        }
                        if (data.Result.Items[i].ItemValue == 4) {
                            rowHtml = rowHtml + '<lable id="PropertyStatus">无效</lable>'
                        }
                        rowHtml = rowHtml + '<input type="hidden" class="PropertyStatus" value="' + data.Result.Items[i].ItemValue + '" /></span>';
                        if (systemParameterType == 27) {
                            if (data.Result.Items[i].ItemNo == "" || data.Result.Items[i].ItemNo == null) {
                                rowHtml = rowHtml + '<i class="l delinfo" onclick="systemParameterSettings.DelSysParameterItem(this);"></i>';
                            }
                        }
                        else {
                            if (data.Result.Items[i].CanDelete) {
                                rowHtml = rowHtml + '<i class="l delinfo" onclick="systemParameterSettings.DelSysParameterItem(this);"></i>';
                            }
                        }
                        rowHtml = rowHtml + '</div>';
                        $("#editArguments").append(rowHtml);
                    }
                }
                $("#editArguments").append('<div class="tc mt20"><input type="button" class="btn-big-orange editSave" value="保存" /></div>');
            }
            //只有房源跟进状态才显示这个
            if (systemParameterType == 64) {
                $("#editArguments .sysValue").css("display", "inline-block");
                $("#editArguments .txtItemValue").attr("notnull", "1");
                $("#editArguments .txtItemValue").attr("isvaluesame", "1");
            }
            else {
                $("#editArguments .sysValue").css("display", "none");
                $("#editArguments .txtItemValue").removeAttr("notnull");
                $("#editArguments .txtItemValue").removeAttr("isvaluesame");
            }
            //如果不是房源状态就隐藏
            if (systemParameterType == 83) {
                $("#editArguments .spanPropertyStatus").css("display", "inline-block")
            }
            else {
                $("#editArguments .spanPropertyStatus").css("display", "none");
            }
            //当时房源标签的时候，需要选择颜色
            if (systemParameterType == 27 || systemParameterType == 58) {
                $("#editArguments .sysStyle").css("display", "inline-block");
                $("#editArguments .txtstyle").attr("notnull", "1");
            }
            else {
                $("#editArguments .sysStyle").css("display", "none");
                $("#editArguments .txtstyle").removeAttr("notnull");
            }
            //调用
            $.dialog({
                id: "dialogEditSystemParameterSettings",
                lock: true,
                title: sysParamTypeName,
                content: '<span id="editSystemParameter">  <input type="hidden" class="addSystemParameterType" id="editSystemParameterTypeId" value="' + systemParameterType + '" /> ' + $("#editArguments").html() + '</span>'
            });
            //验证输入框
            systemParameterSettings.verify("#editSystemParameter input[isint=1]", "#editSystemParameter input[notnull=1]", "#editSystemParameter input[issame=1]", "#editSystemParameter input[isstylesame=1]", "#editSystemParameter input[isvaluesame=1]", "#editSystemParameter");
            //板顶选择颜色控件
            systemParameterSettings.bindStyleControl();
            //保存编辑后的参数项数据
            systemParameterSettings.editSystemParameter();
        });

    });
    //编辑时绑定选择颜色控件
    systemParameterSettings.bindStyleControl = function () {
        var i = 0;
        $("#editSystemParameter").find(".seqItem").each(function () {
            i++;
            if (i > 0) {
                $(this).find(".txtstyle").unbind();
                var lastDepartName = $(this).find(".txtstyle").attr("id", "f" + i);
                $("#editSystemParameter #" + lastDepartName.attr("id") + "").bigColorpicker(lastDepartName.attr("id"), "L", 10);
            }
        });
        $("#f333").bigColorpicker("f3", "L", 6);
    };
    //编辑事件 end



    //选择字段,保存数据 start
    //保存选择字段项数据
    systemParameterSettings.editSelectFieldItem = function () {
        $("#editSelectFieldSpan").find(".editSelectField").click(function () {
            var SelectItemNames = []
            //获取多个值
            $("#editSelectFieldSpan").find(".editSelectFieldItem input:checked").each(function () {
                SelectItemNames[SelectItemNames.length] = $(this).val();
            });
            var url = "/System/Save-SysParameterRelation";
            var reqData = {
                "ParameterType": $("#editSelectFieldSpan").find(".editSelectFieldItemType").val(),
                "AssociatedItemKeyIds": SelectItemNames.join(","),
            };
            $.AjaxAgency(url, reqData, function (data) {
                if (data == "OK") {
                    $.OKDialogAgency('<div class="tc">操作成功！</div>', '提示', function () {
                        art.dialog.get("dialogEditSelectField").close();
                        window.location.reload();
                    });
                }
                else {
                    $.OKDialogAgency('<div class="tc">' + data + '</div>');
                }
            });
        });
    };
    //选择字段
    $(".argumentsSet .selectField").bind("click", function () {
        //获取参数枚举类型值
        var systemParameterType = $(this).attr("sysParaType");
        //获取参数类型名称
        var sysParamTypeName = $(this).parent().parent().prev().text();
        //项关联的父级枚举值
        var parentType = $(this).attr("parentType");
        var url = "/System/Find-SysParameterDetail";
        var reqData = {
            //获取选择字段类型的参数的枚举值
            "ParameterType": systemParameterType
        };
        $.AjaxAgency(url, reqData, function (data) {
            if (data.Flag) {
                //先清空，在拼接
                $(".editSelectField").empty();

                var SelectItems = [], SelectItemsKeyId = []
                $(".editSelectField").append('<div class="selectField-con editSelectFieldItem">');
                //获取房源跟进类型
                if (parentType == 29) {
                    $(".argumentsSet").find(".selectItemsPropertyFollowType").each(function () {
                        SelectItems[SelectItems.length] = $(this).text();
                        SelectItemsKeyId[SelectItemsKeyId.length] = $(this).attr("keyId");
                    });
                }
                //获取客源的跟进类型
                if (parentType == 60) {
                    $(".argumentsSet").find(".selectItemsInquiryFollowType").each(function () {
                        SelectItems[SelectItems.length] = $(this).text();
                        SelectItemsKeyId[SelectItemsKeyId.length] = $(this).attr("keyId");
                    });
                }
                //弹层显示拼接的元素
                if (SelectItems.length == SelectItemsKeyId.length) {
                    for (var i = 0; i < SelectItems.length; i++) {
                        if ($.inArray(SelectItemsKeyId[i], data.Result.AssociatedItemKeyIds) > -1) {
                            $(".editSelectFieldItem").append('<label class="mr4"><input type="checkbox" checked="checked" value="' + SelectItemsKeyId[i] + '" />' + SelectItems[i] + '</label>');
                        }
                        else {
                            $(".editSelectFieldItem").append('<label class="mr4"><input type="checkbox" value="' + SelectItemsKeyId[i] + '" />' + SelectItems[i] + '</label>');
                        }
                    }
                }
                $(".editSelectField").append('<div class="info-list tr"><input type="button" class="btn-red editSelectField" value="保存" /></div>');
            }
            $.dialog({
                id: "dialogEditSelectField",
                lock: true,
                title: sysParamTypeName + "选择字段",
                content: '<span id="editSelectFieldSpan">  <input type="hidden" class="editSelectFieldItemType" id="editSelectFieldItemTypeId" value="' + systemParameterType + '" /> ' + $(".editSelectField").html() + '</span>'
            });
            //保存编辑后的参数项数据
            systemParameterSettings.editSelectFieldItem();
        });
    });
    //选择字段 保存数据 end


    //标签click事件切换
    $(".ExternalResourcesLi").click(function () {
        $(".tab-panel").hide();
        $(".current").removeClass("current");
        $(".ExternalResourcesDiv").css("display", "block");
        $(".ExternalResourcesLi").addClass("current");
    });
    $(".argumentsSetLi").click(function () {
        $(".tab-panel").hide();
        $(".current").removeClass("current");
        $(".argumentsSet").css("display", "block");
        $(".argumentsSetLi").addClass("current");
    });
    $(".AppconfigLi").click(function () {
        $(".tab-panel").hide();
        $(".current").removeClass("current");
        $(".AppconfigDiv").css("display", "block");
        $(".AppconfigLi").addClass("current");
    });
    //系统开关
    $(".SystemOnOffLi").click(function () {
        $(".tab-panel").hide();
        $(".current").removeClass("current");
        $(".SystemOnOff").css("display", "block");
        $(".SystemOnOffLi").addClass("current");
    });
    if (typeof (ReadFileFromFileServer) != "undefined") {
        //这个ReadFileFromFileServer方法是在图片服务器的action里面写的
        var appconfigstr = ReadFileFromFileServer();
        var appconfig = JSON.parse(appconfigstr);
        $("#cmdVirtualCall").val(appconfig.VirtualCall);
        $("#txtCallLimit").val(appconfig.CallLimit);
    }
    agencyVerify.nonnegativeIntInput("#txtCallLimit", false);
    agencyVerify.nonnegativeIntInput("#cleanunLoginAccount", false);
    agencyVerify.nonnegativeIntInput("#cleandelete", false);
    agencyVerify.nonnegativeIntInput("#reserveAutoStop", false);
    $("#btnAppconfig").click(function () {
        var Appconfigdata = {};
        Appconfigdata.VirtualCall = $("#cmdVirtualCall").val();
        Appconfigdata.CallLimit = $("#txtCallLimit").val();
        var postdata = JSON.stringify(Appconfigdata);
        $.AjaxAgency("moblieappsetting-update", { txt: postdata, filename: "Appconfig.html" }, function (data) {
            if (data == "OK") {
                $.OKDialogAgency('<div class="tc">更新成功</div>');
            }
            else {
                $.OKDialogAgency('<div class="tc">' + data + '</div>');
            }
        });
    });

    $("#btnSystemOnOff").click(function () {
        if ($("#cleanunLoginAccount").val().length==0) {
            $.OKDialogAgency('<div class="tc">清理未登录帐号值不能为空</div>');
            return;
    } else if( $("#cleandelete").val().length==0){
        $.OKDialogAgency('<div class="tc">清理已标记删除部门值不能为空</div>');
        return;
    }

        //预定自动转暂停的天数
        //if ($("#reserveAutoStop").val().trim().length == 0) {
        //        $.OKDialogAgency('<div class="tc">预定房源自动转暂停天数不能为空</div>');
        //        return;
        //    } 
        var Appconfigdata = {};
        //虚拟号开关参数
        Appconfigdata.VirtualCalls = $("#cmdVirtualCalls").val();
        Appconfigdata.VirtualCallsID = $("#txtVirtualCalls").val();
        Appconfigdata.VirtualCallsName = $("#txtVirtualCallsName").val();
        //签约是否屏蔽业主电话
        Appconfigdata.TrustorsMobile = $("#cmdTrustorsMobile").val();
        Appconfigdata.TrustorsMobileID = $("#txtTrustorsMobile").val();
        Appconfigdata.TrustorsMobileName = $("#txtTrustorsMobileName").val();
        //客源等级联动
        Appconfigdata.CustomerLever = $("#cmdCustomerLever").val();
        Appconfigdata.CustomerLeverID = $("#txtCustomerLever").val();
        Appconfigdata.CustomerLeverName = $("#txtCustomerLeverName").val();
        //资料客是否显示
        Appconfigdata.InquiryData = $("#cmdInquiryData").val();
        Appconfigdata.InquiryDataID = $("#txtInquiryData").val();
        Appconfigdata.InquiryDataName = $("#txtInquiryDataName").val();

        //新开盘自动转盘
        Appconfigdata.NewOpening = $("#cmdNewOpening").val();
        Appconfigdata.NewOpeningID = $("#txtNewOpening").val();
        Appconfigdata.NewOpeningName = $("#txtNewOpeningName").val();

        //业主委托开关参数
        Appconfigdata.RegisterTrusts = $("#cmdRegisterTrusts").val();
        Appconfigdata.RegisterTrustsID = $("#txtRegisterTrustsID").val();
        Appconfigdata.RegisterTrustsName = $("#txtRegisterTrustsName").val();
        //业主委托审核放盘开关参数
        Appconfigdata.RegisterTrustAudit = $("#cmdRegisterTrustAudit").val();
        Appconfigdata.RegisterTrustAuditID = $("#txtRegisterTrustAuditID").val();
        Appconfigdata.RegisterTrustAuditName = $("#txtRegisterTrustAuditName").val();
        //清理多少天未登陆帐号
        Appconfigdata.CleanunLoginAccount = $("#cleanunLoginAccount").val();
        Appconfigdata.CleanunLoginAccountID = $("#txtCleanunLoginAccountKeyId").val();
        Appconfigdata.CleanunLoginAccountName = $("#txtCleanunLoginAccountName").val();
        //清理未删除标记
        Appconfigdata.CleanDelete = $("#cleandelete").val();
        Appconfigdata.CleanDeleteID = $("#txtCleanDeleteKeyId").val();
        Appconfigdata.CleanDeleteName = $("#txtCleanDeleteName").val();
        //发送验证码
        Appconfigdata.SendCode = $("#cmdMobileCode").val();
        Appconfigdata.SendCodeID = $("#txtSendCodeKeyId").val();
        Appconfigdata.SendCodeName = $("#txtSendCodeName").val();
        //预定自动转暂停的天数
        Appconfigdata.reserveAutoStop = $("#reserveAutoStop").val();
        Appconfigdata.reserveAutoStopID = $("#txtRreserveAutoStopKeyId").val();
        Appconfigdata.reserveAutoStopName = $("#txtReserveAutoStopName").val();

        Appconfigdata.PendingCloningSwitch = $("#cmdPendingCloningSwitch").val();
        Appconfigdata.PendingCloningSwitchID = $("#PendingCloningSwitchID").val();
        Appconfigdata.PendingCloningSwitchName = $("#PendingCloningSwitchName").val();
        //有默认内容情况下是否允许业务员修改
        Appconfigdata.DefaultDescription = $("#cmDefaultDescription").val();
        Appconfigdata.DefaultDescriptionID = $("#DefaultDescriptionID").val();
        Appconfigdata.DefaultDescriptionName = $("#DefaultDescriptionName").val();
        //有默认周边配置是否允许业务员修改
        Appconfigdata.PeripheryMatching = $("#cmPeripheryMatching").val();
        Appconfigdata.PeripheryMatchingID = $("#PeripheryMatchingID").val();
        Appconfigdata.PeripheryMatchingName = $("#PeripheryMatchingName").val();
        
        $.AjaxAgency("Modify-SystemOnOff", Appconfigdata, function (data) {
            if (data == "OK") {
                $.OKDialogAgency('<div class="tc">更新成功</div>');
            }
            else {
                $.OKDialogAgency('<div class="tc">' + data + '</div>');
            }
        });
    });
});


//外部资源编辑
systemParameterSettings.editExternalResourceItem = function () {
    //外部资源编辑
    $(".ExternalResourcesDiv .editExternalResource").unbind("click");
    $(".ExternalResourcesDiv .editExternalResource").bind("click", function () {
        //获取当前元素的的属性值
        var keyId = $(this).attr("keyId");
        var preCurret = $(this).parent().prev().find(".externalResourceItemNameSpan");
        $.dialog({
            id: "dialogeditExternalResource",
            lock: true,
            title: "外部资源",
            content: '<span id="spanTest">' + $(this).parent().prev().find(".editexternalResourceItem").html() + '</span>'
        });
        //弹框后复制修改的值
        $("#spanTest .txtIexternalResourcetemName").val(preCurret.text());
        $("#spanTest .addSystemParameter").click(function () {
            var url = "/System/Modify-ExternalResourceItem";
            var reqData = {
                //获取选择字段类型的参数的枚举值
                "KeyId": keyId,
                //获取当前元素的值
                "ItemValue": $("#spanTest .txtIexternalResourcetemName").val()
            };
            $.AjaxAgency(url, reqData, function (data) {
                if (data == "OK") {
                    preCurret.text(reqData.ItemValue);
                    $.OKDialogAgency('<div class="tc">操作成功！</div>', '提示', function () {
                        art.dialog.get("dialogeditExternalResource").close();
                    });
                }
                else {
                    $.OKDialogAgency('<div class="tc">' + data + '</div>');
                }
            });
        });
    });
};


//用于滚动到之前操作的位置
var _h = 0;
window.onscroll = function () {
    _h = $(document).scrollTop();
    SetCookie("a", _h)
}
window.onload = function () { $(document).scrollTop(GetCookie("a")); }
function SetCookie(sName, sValue) {
    document.cookie = sName + "=" + escape(sValue) + "; ";
}
function GetCookie(sName) {
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    return 0;
}



